import React, { FC } from 'react'
import ReactDOM from 'react-dom/client'
import { ConfigProvider } from 'antd'
import zhCN from 'antd/es/locale/zh_CN'

import { QueryClientProvider, QueryClient } from 'react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
import 'virtual:windi.css'

import App from './App'
import { makeServer } from './servers/mirage'
// 判断当前环境，如果是本地开发，才启动 mock 服务
if (process.env.NODE_ENV === 'development') {
  makeServer()
}

const queryClient = new QueryClient()

const Root: FC = () => {
  return (
    <React.StrictMode>
      <QueryClientProvider client={queryClient}>
        <ConfigProvider locale={zhCN}>
          <App />
          <ReactQueryDevtools />
        </ConfigProvider>
      </QueryClientProvider>
    </React.StrictMode>
  )
}

ReactDOM.createRoot(document.getElementById('root')!).render(<Root />)
